﻿<!DOCTYPE html>
<html>

<head>
    <meta charset="utf-8" />
    <title>会员卡订单</title>
    <link href="/style/rightdirectory.css" rel="stylesheet" />
    <script src="/script/config.js"></script>
</head>
<style>
    th {
        text-align: center;
    }
    td {
        text-align: center;
    }
   
</style>
<body>
    <div class="view-page">
        <!--搜索区域-->
        <div class="view-search inline">
            <div class="form-inline">
                <div class="form-group col-sm-2">
                    <div class="input-group">
                        <span class="input-group-addon">购买人名称</span>
                        <input id="query" type="text" class="form-control" data-form="RealName" placeholder="购买人名称">
                    </div>
                </div>

                <div class="form-group col-sm-1">
                    <button type="button" id="btn-search" class="btn btn-primary">
                        <i class="fa fa-search"></i> 搜索
                    </button>
                </div>
            </div>
        </div>
        
        <div class="view-data">
            <table id="table" class="table table-bordered table-hover" data-post="">
                <thead>
                    <tr>
                        <th>
                            ID
                        </th>
                        <th>订单号</th>
                        <th>购买人名称</th>
                        <th>支付方式</th>
                        <th>原价总额</th>
                        <th>支付总额</th>
                        <th>订单状态</th>
                        <th>支付服务商订单编号</th>
                        <th>付款时间</th>
                        <th>卡过期时间</th>
                        <th>创建时间</th>
                    </tr>
                </thead>
                <tbody></tbody>
            </table>
            <!--分页条 默认选择id=list-page元素-->
            <div id="list-page" class="view-pagination-page"></div>
        </div>
    </div>

    
</body>

</html>
<script type="text/html" id="tp-table">
    {{each list d}}
    <tr>
        <td>
            {{d.Id}}
        </td>
        <td><a class="detail" href="javascript:;" onclick="openDetail('{{d.OrderNo}}')">{{d.OrderNo}}</a></td>
        <td>{{d.RealName}}</td>
        <td>{{d.PayName}}</td>
        <td>{{d.OriginalPrice}}</td>
        <td>{{d.PayPrice}}</td>
        {{if d.Status==1}}
        <td>未支付</td>
        {{else if d.Status==2}}
        <td>支付成功</td>
        {{/if}}
        <td>{{d.PayServiceOrderNo}}</td>
        <td>{{d.PayDate|to_date}}</td>
        <td>{{d.ExpiresDate|to_date}}</td>
        <td>{{d.CreateDate|to_date}}</td>
    </tr>
    {{/each}}
</script>

<script type="text/html" id="tp-order-detail">
    <div id="layre-order-detail" style="padding:10px">
        <div class="panel" id="tem">
            <div class="panel-heading">订单详细</div>
            <div class="panel-body">
                <table class="table table-bordered">
                    <thead>
                        <tr>
                            <th>订单号</th>
                            <th>支付服务商订单编号</th>
                            <th>购买人名称</th>
                            <th>支付方式</th>
                            <th>付款时间 </th>
                            <th>原价总额</th>
                            <th>支付总额</th>
                            <th>订单状态 </th>
                            <th>创建时间</th>
                            <th>卡过期时间</th>
                        </tr>
                    </thead>
                    <tbody></tbody>
                </table>
            </div>
        </div>
    </div>
</script>

<script type="text/html" id="det-temp">
    {{set d=list}}
    <tr>
        <td>{{d.OrderNo}}</td>
        <td>{{d.PayServiceOrderNo}}</td>
        <td>{{d.RealName}}</td>
        <td>{{d.PayName}}</td>
        <td>{{d.PayDate|to_date}}</td>
        <td>{{d.OriginalPrice}}</td>
        <td>{{d.PayPrice}}</td>
        {{if d.Status}}
        <td>未支付</td>
        {{else if d.Status}}
        <td>支付成功</td>
        {{/if}}
        <td>{{d.CreateDate|to_date}}</td>
        <td>{{d.ExpiresDate|to_date}}</td>
    </tr>
   
</script>

<script type="text/javascript">
    $(function () {
        function _LoadData() {
            var parm = $(".view-search").getFormData();
            $("#table").ajaxPageTable("buycustomercardorder/list", parm, function (d) {               
                $("#table>tbody").append(template("tp-table", {
                    list: d
                }));
            })
        }
        _LoadData();//初启化
        $("#query").focus(function () { //搜索按钮
            $("#query").keydown(function(e) {
                if (e.keyCode == 13) {
                    _LoadData();
                }
            })
        })
        $("#btn-search").click(function() { //搜索按钮
            _LoadData();
        })

        
    })

    function openDetail(o) {  //弹出订单详情

        $.layrePage({  //弹出
            area: ["90%", "800px"],
            title: "-",
            offset: "6px",
            content: template("tp-order-detail", {})
        });

        $.http.json("buycustomercardorder/find", { OrderNo: o }, { //发出请求
            pass: function (d) {
                
                $("#layre-order-detail #tem table>tbody").append(template("det-temp", { //订单详情
                    list: d
                }));
            },
            error: function (d) {
                console.log(d)
            }
        })

    }
</script>